<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>添加文章栏目</title>
    <meta name="keywords" content="S.Hackles--后台管理系统">
    <meta name="description" content="S.Hackles--后台管理系统">

    <link rel="shortcut icon" href="/favicon.ico">
    <link href="/Public/Admin/css/bootstrap.min14ed.css" rel="stylesheet">
    <link href="/Public/Admin/css/font-awesome.min93e3.css" rel="stylesheet">
    <link href="/Public/Admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <!-- Gritter -->
    <link href="/Public/Admin/js/plugins/gritter/jquery.gritter.css" rel="stylesheet">
    <!-- Morris -->
    <link href="/Public/Admin/css/plugins/morris/morris-0.4.3.min.css" rel="stylesheet">
    <link href="/Public/Admin/css/animate.min.css" rel="stylesheet">
    <link href="/Public/Admin/css/style.min862f.css" rel="stylesheet">
    <link href="/Public/Admin/css/plugins/switchery/switchery.css" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加文章栏目</h5>
                </div>
                <div class="ibox-content">
                    <div class="row m-b-sm m-t-sm">
                        <div class="col-md-2">
                            <a href="<?php echo U('Admin/artcate/index');?>" class="btn btn-outline btn-primary">返回文章栏目列表</a>
                        </div>
                    </div>
                    <form class="form-horizontal m-t" id="addForm" action="<?php echo U('Admin/Artcate/Save');?>">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">栏目名称:</label>
                            <div class="col-sm-8">
                                <input id="title" name="title" class="form-control" value="<?php echo ($artcateInfo["title"]); ?>" type="text">
                                <input type="hidden"  value="<?php echo ($artcateInfo["id"]); ?>" name="id" id="id">
                                <input type="hidden"  value="<?php echo ($pid); ?>" name="pid" id="pid">
                                <span class="help-block m-b-none"></span>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">英文名称:</label>
                            <div class="col-sm-8">
                                <input id="columns" name="columns" class="form-control" value="<?php echo ($artcateInfo["columns"]); ?>" type="text">
                                <span class="help-block m-b-none"></span>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">SEO标题:</label>
                            <div class="col-sm-8">
                                <input id="seo_title" name="seo_title" class="form-control" value="<?php echo ($artcateInfo["seo_title"]); ?>" type="text">
                                <span class="help-block m-b-none"></span>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">SEO关键词:</label>
                            <div class="col-sm-8">
                                <input id="seo_keyword" name="seo_keyword" class="form-control" value="<?php echo ($artcateInfo["seo_keyword"]); ?>" type="text">
                                <span class="help-block m-b-none"></span>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">SEO描述:</label>
                            <div class="col-sm-8">
                                <input id="seo_description" name="seo_description" class="form-control" value="<?php echo ($artcateInfo["seo_description"]); ?>" type="text">
                                <span class="help-block m-b-none"></span>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">排序:</label>
                            <div class="col-sm-8">
                                <input id="px" name="px" class="form-control" value="<?php echo ($artcateInfo["px"]); ?>" type="text" aria-required="true" aria-invalid="false" class="valid">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">状态:</label>
                            <div class="col-sm-8">
                                <input type="checkbox" class="js-switch form-control" value="1" data-value="<?php echo ($artcateInfo["status"]); ?>" name="status" id="status" <?php if($artcateInfo["status"] == 1): ?>checked<?php endif; ?>/>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button class="btn btn-primary" type="submit">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/Public/Admin/js/jquery.min.js"></script>
<script src="/Public/Admin/js/bootstrap.min.js"></script>
<script src="/Public/Admin/js/plugins/layer.3/layer.js"></script>
<script src="/Public/Admin/js/common.js"></script>
<script src="/Public/Admin/js/content.min.js"></script>
<script src="/Public/Admin/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/Public/Admin/js/plugins/validate/messages_zh.min.js"></script>
<script src="/Public/Admin/js/plugins/switchery/switchery.js"></script>
<script>
    var elem = document.querySelector('.js-switch');
    var init = new Switchery(elem);

    $(function(){
        $.validator.setDefaults({
            highlight: function (e) {
                $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
            }, success: function (e) {
                e.closest(".form-group").removeClass("has-error").addClass("has-success")
            }, errorElement: "span", errorPlacement: function (e, r) {
                e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
            }, errorClass: "help-block m-b-none", validClass: "help-block m-b-none"
        }), $().ready(function () {
            var e = "<i class='fa fa-times-circle'></i> ";

            $("#addForm").validate({
                rules: {
                    title: "required",
                    columns: "required",
                    seo_title: "required",
                    seo_keyword: "required",
                    seo_description: "required",
                    px: "required"
                },
                messages: {
                    title: e + "请输入文章栏目名称",
                    columns: e + "请输入英文名称",
                    seo_title: e + "请输入SEO标题名称",
                    seo_keyword: e + "请输入SEO关键词",
                    seo_description: e + "请输入SEO描述",
                    px: e + "请输入栏目排序"
                },
                submitHandler: function(form){
                    var objectArr = $(form).serializeArray();
                    var data = new Object();
                    $.each(objectArr,function(k,v){
                        data[v.name] = v.value;
                    });

                    $.post(
                        "<?php echo U('Admin/artcate/Save');?>",
                        data,
                        function(data){
                            if(data.status > 0){
                                common.error(data.msg);
                            }else{
                                common.success(data.msg,"<?php echo U('Admin/artcate/index');?>");
                            }
                        },
                        'JSON'
                    );
                }
            });
        });

    });
</script>
</body>
</html>